#include <typescommon.h>
#include <inttypes.h>
struct lstr
{
    char str[32];
};
// c string from long
struct lstr cstrfl(long val)
{
    struct lstr tmpstr;
    snprintf(tmpstr.str, sizeof(tmpstr.str), "%ld", val);
    return tmpstr;
}
// c string from unsigned long
struct lstr cstrflu(unsigned long val)
{
    struct lstr tmpstr;
    snprintf(tmpstr.str, sizeof(tmpstr.str), "%lu", val);
    return tmpstr;
}
// c string from float
struct lstr cstrff(float val)
{
    struct lstr tmpstr;
    snprintf(tmpstr.str, sizeof(tmpstr.str), "%f", val);
    return tmpstr;
}
long cstrtol(char *instr)
{
    long tmpval;
    sscanf(instr, "%ld", &tmpval);
    return tmpval;
}
unsigned long cstrtolu(char *instr)
{
    unsigned long tmpval;
    sscanf(instr, "%lu", &tmpval);
    return tmpval;
}

int main(int argc, char **argv)
{
    int tmpval;
    struct lstr tmpstr;
    tmpval = 12345678;
    logdebug("%s", cstrfl(tmpval).str);
    tmpstr = cstrfl(tmpval);
    logdebug("%s", tmpstr.str);
    float tmpf = atof(tmpstr.str);
    logdebug("%f", tmpf);
    tmpstr = cstrff(tmpf);
    logdebug("%s", tmpstr.str);
    tmpval = cstrtol(tmpstr.str);
    logdebug("%d", tmpval);
    return 1;
}
